<?php

namespace app\admin\model\gas;

use think\Model;


class Gasset extends Model
{

    

    

    // 表名
    protected $name = 'gasset';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'gas_type_text',
        'unit_type_text',
        'status_text'
    ];
    

    
    public function getGasTypeList()
    {
        return ['1' => __('汽油'), '2' => __('柴油'), '3' => __('天然气')];
    }
    
     public function getGasUnitList()
    {
        return ['1' => __('L'), '2' => __('kg'), '3' => __('m³'), '4' => __('升'), '5' => __('公斤')];
    }

    public function getUnitTypeList()
    {
        return ['0' => __('元'), '2' => __('计价单位')];
    }

    public function getStatusList()
    {
        return ['0' => __('关闭'), '2' => __('启用')];
    }


    public function getGasTypeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['gas_type']) ? $data['gas_type'] : '');
        $list = $this->getGasTypeList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getUnitTypeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['unit_type']) ? $data['unit_type'] : '');
        $list = $this->getUnitTypeList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getStatusTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
        $list = $this->getStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }




}
